import request from '@/utils/request'

// 获取首页统计数据
export function getHomeStats() {
  return request({
    url: '/api/admin/dashboard/stats',
    method: 'get'
  })
}

// 获取最近订单
export function getRecentOrders() {
  return request({
    url: '/api/admin/dashboard/recent-orders',
    method: 'get'
  })
}

// 获取待处理预约
export function getPendingAppointments() {
  // 实际API接口
  // return request({
  //   url: '/home/pending-appointments',
  //   method: 'get'
  // })
  
  // 临时模拟数据
  return Promise.resolve({
    data: [
      { 
        appointmentNo: 'AP20230502001', 
        type: 'MEASUREMENT', 
        designerName: '张设计师', 
        appointmentTime: '2023-05-05 10:00:00' 
      },
      { 
        appointmentNo: 'AP20230501002', 
        type: 'DESIGN_CONSULTATION', 
        designerName: '李设计师', 
        appointmentTime: '2023-05-04 14:30:00' 
      },
      { 
        appointmentNo: 'AP20230430003', 
        type: 'FITTING', 
        designerName: '王设计师', 
        appointmentTime: '2023-05-03 16:00:00' 
      },
      { 
        appointmentNo: 'AP20230429004', 
        type: 'GENERAL_CONSULTATION', 
        designerName: '赵设计师', 
        appointmentTime: '2023-05-02 11:30:00' 
      }
    ]
  })
}

// 获取推荐设计
export function getRecommendDesigns() {
  // 实际API接口
  // return request({
  //   url: '/home/recommend-designs',
  //   method: 'get'
  // })
  
  // 临时模拟数据
  return Promise.resolve({
    data: [
      { 
        id: 1, 
        title: '简约商务西装', 
        designerName: '张设计师', 
        coverUrl: 'https://pic.616pic.com/bg_w1180/00/07/20/NNXzT0ESgx.jpg!/fw/1120', 
        likeCount: 128 
      },
      { 
        id: 2, 
        title: '中式复古礼服', 
        designerName: '李设计师', 
        coverUrl: 'https://pic.616pic.com/bg_w1180/00/04/34/MNSBKHj7Jj.jpg!/fw/1120', 
        likeCount: 86 
      },
      { 
        id: 3, 
        title: '时尚休闲套装', 
        designerName: '王设计师', 
        coverUrl: 'https://pic.616pic.com/bg_w1180/00/04/08/67CW1JC8wP.jpg!/fw/1120', 
        likeCount: 92 
      },
      { 
        id: 4, 
        title: '优雅连衣裙', 
        designerName: '赵设计师', 
        coverUrl: 'https://pic.616pic.com/bg_w1180/00/07/10/4SJmuU1qCN.jpg!/fw/1120', 
        likeCount: 64 
      },
      { 
        id: 5, 
        title: '复古牛仔外套', 
        designerName: '孙设计师', 
        coverUrl: 'https://pic.616pic.com/bg_w1180/00/04/10/g4OZ156p6P.jpg!/fw/1120', 
        likeCount: 75 
      }
    ]
  })
}

// 获取近期活动
export function getRecentActivities() {
  // 实际API接口
  // return request({
  //   url: '/home/recent-activities',
  //   method: 'get'
  // })
  
  // 临时模拟数据
  return Promise.resolve({
    data: [
      { 
        content: '您的订单 DD20230501001 已进入生产阶段', 
        time: '2023-05-02 14:30:25', 
        type: 'ORDER', 
        color: '#409EFF' 
      },
      { 
        content: '您预约的设计师 张设计师 已确认上门量体时间', 
        time: '2023-05-01 10:15:36', 
        type: 'APPOINTMENT', 
        color: '#67C23A' 
      },
      { 
        content: '您收藏的设计师 李设计师 发布了新作品', 
        time: '2023-04-30 16:42:18', 
        type: 'DESIGN', 
        color: '#E6A23C' 
      },
      { 
        content: '您的定制申请 CU20230428005 已通过审核', 
        time: '2023-04-28 09:28:45', 
        type: 'SYSTEM', 
        color: '#909399' 
      },
      { 
        content: '您的账户已成功注册并完成实名认证', 
        time: '2023-04-25 11:05:32', 
        type: 'SYSTEM', 
        color: '#67C23A' 
      }
    ]
  })
}

export default {
  // 获取管理员仪表盘统计数据
  getHomeStats() {
    return request({
      url: '/api/admin/dashboard/stats',
      method: 'get'
    })
  },
  
  // 获取最近订单
  getRecentOrders() {
    return request({
      url: '/api/admin/dashboard/recent-orders',
      method: 'get'
    })
  },
  
  // 获取最新用户
  getRecentUsers() {
    return request({
      url: '/api/admin/dashboard/recent-users',
      method: 'get'
    })
  },
  
  // 获取系统日志
  getSystemLogs(type = 'all') {
    return request({
      url: '/api/admin/dashboard/system-logs',
      method: 'get',
      params: { type }
    })
  },
  
  // 获取订单图表数据
  getOrderChartData(type = 'month') {
    return request({
      url: '/api/admin/dashboard/order-chart',
      method: 'get',
      params: { type }
    })
  },
  
  // 获取用户图表数据
  getUserChartData(type = 'role') {
    return request({
      url: '/api/admin/dashboard/user-chart',
      method: 'get',
      params: { type }
    })
  }
} 